<template>
  <div class="not-found-container">
    <div class="not-found-content">
      <div class="illustration">
        <svg viewBox="0 0 560 200" class="svg-illustration">
          <!-- 云朵 -->
          <path class="cloud" d="M120,80 Q140,60 160,70 Q180,60 200,75 Q220,65 240,80 Q250,90 240,100 Q220,110 200,100 Q180,115 160,100 Q140,110 120,100 Q110,90 120,80 Z" />
          <path class="cloud small" d="M320,60 Q330,50 340,55 Q350,45 360,60 Q365,65 360,70 Q350,75 340,70 Q330,80 320,70 Q315,65 320,60 Z" />
          
          <!-- 数字404 -->
          <text x="50%" y="120" text-anchor="middle" class="error-code">404</text>
          
          <!-- 装饰元素 -->
          <circle cx="100" cy="40" r="3" class="dot" />
          <circle cx="450" cy="30" r="2" class="dot" />
          <circle cx="500" cy="80" r="4" class="dot" />
        </svg>
      </div>
      
      <div class="message">
        <h1 class="title">哎呀！页面迷路了</h1>
        <p class="description">
          抱歉，您要访问的页面似乎不存在或已被移除。<br>
          请检查URL是否正确，或返回首页继续浏览。
        </p>
        
        <div class="actions">
          <el-button type="primary" @click="goHome" size="large" class="action-btn">
            <el-icon><House /></el-icon>
            返回首页
          </el-button>
          <el-button @click="goBack" size="large" class="action-btn">
            <el-icon><ArrowLeft /></el-icon>
            返回上一页
          </el-button>
        </div>
        
        <div class="search-section">
          <p class="search-tip">或者试试搜索您需要的内容：</p>
          <div class="search-box">
            <el-input 
              v-model="searchKeyword" 
              placeholder="输入关键词搜索..." 
              size="large"
              @keyup.enter="handleSearch"
            >
              <template #append>
                <el-button :icon="Search" @click="handleSearch" />
              </template>
            </el-input>
          </div>
        </div>
      </div>
    </div>
    
    <div class="footer">
      <p>© {{ currentYear }} SecondHandHiveMall. All rights reserved.</p>
    </div>
  </div>
</template>

<script setup>
import { ref } from 'vue'
import { useRouter } from 'vue-router'
import { House, ArrowLeft, Search } from '@element-plus/icons-vue'

const router = useRouter()
const searchKeyword = ref('')
const currentYear = new Date().getFullYear()

const goHome = () => {
  router.push('/')
}

const goBack = () => {
  router.go(-1)
}

const handleSearch = () => {
  if (searchKeyword.value.trim()) {
    // 跳转到搜索结果页面
    router.push(`/search?q=${encodeURIComponent(searchKeyword.value)}`)
  }
}
</script>

<style scoped>
.not-found-container {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  padding: 20px;
  box-sizing: border-box;
}

.not-found-content {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  max-width: 800px;
  margin: 0 auto;
  text-align: center;
  color: #fff;
}

.illustration {
  margin-bottom: 40px;
}

.svg-illustration {
  width: 100%;
  max-width: 560px;
  height: auto;
}

.error-code {
  font-size: 80px;
  font-weight: 800;
  fill: rgba(255, 255, 255, 0.9);
  text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.3);
}

.cloud {
  fill: rgba(255, 255, 255, 0.8);
  animation: float 6s ease-in-out infinite;
}

.cloud.small {
  animation-delay: 2s;
}

.dot {
  fill: rgba(255, 255, 255, 0.6);
  animation: blink 2s ease-in-out infinite alternate;
}

.dot:nth-child(2) {
  animation-delay: 0.5s;
}

.dot:nth-child(3) {
  animation-delay: 1s;
}

.title {
  font-size: 2.5rem;
  font-weight: 700;
  margin-bottom: 20px;
  color: #fff;
  text-shadow: 1px 1px 2px rgba(0, 0, 0, 0.3);
}

.description {
  font-size: 1.1rem;
  line-height: 1.6;
  margin-bottom: 40px;
  color: rgba(255, 255, 255, 0.9);
}

.actions {
  display: flex;
  gap: 20px;
  justify-content: center;
  margin-bottom: 40px;
  flex-wrap: wrap;
}

.action-btn {
  border-radius: 50px;
  padding: 12px 24px;
  font-size: 1rem;
  transition: all 0.3s ease;
}

.action-btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
}

.search-section {
  width: 100%;
  max-width: 500px;
}

.search-tip {
  margin-bottom: 15px;
  font-size: 1rem;
  color: rgba(255, 255, 255, 0.9);
}

.search-box {
  max-width: 400px;
  margin: 0 auto;
}

.search-box :deep(.el-input-group__append) {
  border-top-right-radius: 20px;
  border-bottom-right-radius: 20px;
  background-color: #409eff;
  border-color: #409eff;
  color: white;
}

.search-box :deep(.el-input__inner) {
  border-radius: 20px 0 0 20px;
  border-color: rgba(255, 255, 255, 0.3);
  background-color: rgba(255, 255, 255, 0.9);
}

.footer {
  text-align: center;
  padding: 20px;
  color: rgba(255, 255, 255, 0.7);
  font-size: 0.9rem;
}

@keyframes float {
  0%, 100% {
    transform: translateY(0px);
  }
  50% {
    transform: translateY(-10px);
  }
}

@keyframes blink {
  0% {
    opacity: 0.4;
  }
  100% {
    opacity: 1;
  }
}

/* 响应式设计 */
@media (max-width: 768px) {
  .title {
    font-size: 2rem;
  }
  
  .description {
    font-size: 1rem;
  }
  
  .error-code {
    font-size: 60px;
  }
  
  .actions {
    flex-direction: column;
    gap: 15px;
  }
  
  .action-btn {
    width: 100%;
    max-width: 300px;
  }
}

@media (max-width: 480px) {
  .not-found-container {
    padding: 10px;
  }
  
  .title {
    font-size: 1.8rem;
  }
  
  .error-code {
    font-size: 50px;
  }
  
  .search-section {
    width: 100%;
  }
}
</style>